//	--------------------------------------------------------------------
//	Copyright(C) 2006,2007 Zhao Yukun. All rights reserved.
//	This file is a part of the Xeres system.
//	Xeres 2007
//	Contact : xeres.engine@gmail.com
//	$(reservedInfo)
//	$(reservedDeclaration)
//	--------------------------------------------------------------------
///	@file	<XFrame.h>
///	@path	~/src/gui/xgui/
///	@date	2008/09/24
///	@brief	.

#pragma once

#include "xeres.h"

#include "gui/xgui/XForm.h"
#include "gui/xgui/XPanel.h"
#include "gui/xgui/XDesktop.h"

namespace xeres {

	// forward declaration
	class ITexture;
	class IRenderer;
	class CCompositeTexture;

	/*! 
		\class	XFrame
		\brief	General frame encapsulation.
	*/
	class XFrame : public XPanel
	{
	public:
		
		/// \ctor
		XFrame( void );

		/// \ctor
		XFrame( const Rect<int>& placement );

		/// \ctor
		XFrame( const Pair<int>& size );

		/// \dtor
		virtual ~XFrame( void );

		DECL_IOBJECT_CLASS_DYNAMIC( XFrame , XPanel );

	public:

		/// \name XGui Component Attributes
		//@{

		/// \brief	Set frame edge.
		virtual void SetFrameEdge( const Pair<int>& edge );

		/// \brief	Get frame edge.
		virtual const Pair<int>& GetFrameEdge( void );

		/// \brief	Set position of component.
		virtual bool SetPosition( const Pair<int>& pos );

		/// \brief	Set size of component.
		virtual bool SetSize( const Pair<int>& size );

		/// \brief	Set parent component.
		virtual bool SetParent( RefWeak<IGuiForm> parent );

		/// \brief	Request update.
		virtual void RequestUpdate( RefWeak<IGuiComp> comp , const Rect<int>& region );

		/// \brief	Call when close window.
		virtual void OnClose( void );

		//@}

		/// \name Presentation Manipulation
		//@{

		/// \brief	Tick update.
		virtual void Tick( Updater& updater , float dTime );

		/// \brief	Draw XGUI component to composition.
		virtual void Draw( Composition& composition );

		/// \brief	Query if frame needs update.
		bool NeedUpdate( void ) const { return !m_updateRect.is_empty(); }

		/// \brief	Query update region.
		const Rect<int>& QueryUpdate( void ) const { return m_updateRect; }

		/// \brief	Validate update.
		void ValidateUpdate( void ) { m_updateRect.empty(); }

		//@}

	protected:

		// @data
		Rect<int>					m_updateRect;
	};

} // namespace xeres
